package com.ruoyi.flow.dubbo;

import com.ruoyi.flow.domain.bo.TWorkflowBo;
import com.ruoyi.flow.domain.vo.TWorkflowVo;
import com.ruoyi.flow.service.ITWorkflowService;
import com.ruoyi.workflow.api.RemoteWorkFlowService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.warm.flow.core.enums.FlowStatus;

import java.util.Optional;

/**
 * @Author Zzneko
 * @Date 2025/7/15 11:23
 * @Descprition
 *
 **/
@DubboService
@RequiredArgsConstructor
public class RemoteWorkFlowServiceImpl implements RemoteWorkFlowService {

    private final ITWorkflowService itWorkflowService;
    @Override
    public String getWorkFlowStatus(String serviceId) {
        TWorkflowBo bo = new TWorkflowBo();
        bo.setServiceId(serviceId);
        Optional<TWorkflowVo> first = itWorkflowService.queryList(bo).stream().findFirst();
        return first.orElseGet(TWorkflowVo::new).getFlowStatus();
    }
}
